<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
<style type="text/css">
    .input1{
        height:34px;
    }
</style>
    <script type="text/javascript">
        //修改密码
        function changePsw() {
            var new1 = $("#pswNewPsw1").val();
            var new2 = $("#pswNewPsw2").val();
            var oldPsw = $("#pswOldPsw").val();
            if (oldPsw == '') {
                layer.tips('请输入旧密码', '#pswOldPsw', {
                    tips: [2, '#FF0000']
                });
                return false;
            }
            if (new1 == '') {
                layer.tips('请输入新密码', '#pswNewPsw1', {
                    tips: [2, '#FF0000']
                });
                return false;
            }
            if (new2 == '') {
                layer.tips('请输入确认密码', '#pswNewPsw2', {
                    tips: [2, '#FF0000']
                });
                return false;
            }
            if (new1 == new2) {
                $.ajax({
                    url: "${basePath}/user/doChangePassword",
                    async: false,
                    type: "POST",
                    data: {"pswNewPsw1": new1, "pswOldPsw": oldPsw},
                    success: function (rst) {
                        if (rst) {
                            layer.msg("密码修改成功,请重新登录系统", {icon: 1}, function () {
                                top.location.href = '${basePath}/security/logout';
                            });
                        } else {
                            layer.msg("密码修改失败，请确认原密码是否正确.", function () {});
                        }
                    },
                    error: function () {
                        layer.msg("密码修改失败.,function(){}");
                    }
                });
            } else {
                layer.msg("新密码与确认密码不一致！", function () {});
                return false;
            }
            return true;
        }

        function closeAll() {
            top.location.href = $basePath + '/portal';
        }
    </script>
</head>
<body>
<div class="content content_frame">
    <h3 class="mainTitle"><img src="${basePath}/images/icon2.png"/>修改密码</h3>
    </br>
    <c:if test="${sessionScope.firstTimeLogin=='Y'}">
        <div class="alert alert-danger" role="alert">您是第一次登陆系统，为了您的账户安全，请先修改登录密码后再重新登录</div>
    </c:if>
    <ul class="contentNav dib-wrap">
        <li class="dib" id="btnSearch" onclick="javascript:changePsw();">
            <a><i class='icon-save'></i>&nbsp;&nbsp;保&nbsp;存 </a>
        </li>
        <li class="dib">
            <a onclick="javascript:closeAll();">
                <i class='icon-remove'></i>&nbsp;&nbsp;取&nbsp;消 </a>
        </li>
        　
    </ul>
    <br/>
    <table class="table3">
        <tr>
            <th colspan="2">密码修改</th>
        </tr>
        <tr>
            <td width="120"><label for="pswOldPsw"><font
                    color="red">*</font>旧密码</label></td>
            <td><input type="password" id="pswOldPsw" name="pswOldPsw"
                       class="input1 required" placeholder="旧密码">
            </td>
        </tr>
        <tr>
            <td width="120"><label for="pswNewPsw2"><font
                    color="red">*</font>新密码</label></td>
            <td><input class="input1 required" placeholder="新密码"
                       type="password" id="pswNewPsw1" name="pswNewPsw1">
            </td>
        </tr>

        <tr>
            <td width="120"><label for="pswNewPsw2"><font
                    color="red">*</font>确认密码</label></td>
            <td><input class="input1 required" placeholder="确认密码"
                       type="password" id="pswNewPsw2" name="pswNewPsw2">
            </td>
        </tr>

    </table>
</div>
　
</body>
</html>
